<?php

namespace Mogod\Core\Controller;

/**
 *
 * Исполнитель заданий контроллера
 *
 * @author goorus, morph
 *
 */
class ControllerTaskWorker
{

	/**
	 * Менеджер сервисов
	 *
	 * @var \Mogod\Core\DependencyInjection\ServiceManager
	 */
	protected $serviceManager;

	/**
	 *
	 * @param \Mogod\Core\DependencyInjection\ServiceManager $serviceManager
	 */
	public function __construct(
		\Mogod\Core\DependencyInjection\ServiceManager $serviceManager)
	{

	}

	/**
	 *
	 * @param ControllerTask $task
	 */
	public function execute($task)
	{
		$controller = $this->serviceManager->get(
			$task->getController(),
			$this
		);

		$controller->execute($task);
	}

}
